<template>
	<div class="content">
		<div class="login">
			<h4>唐山县人力资源管理系统</h4>
			<el-input v-model='account' placeholder="账号" class='elInput'></el-input>
			<el-input v-model='passw' placeholder="密码" class='elInput' type="password"></el-input>
			<div class="btn">
				<el-button type="info" size='small' @click='login'>登录</el-button>
				<el-button type="info" size='small' @click='reset'>重置</el-button>
			</div>

		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				account: '',
				passw: '',
			}
		},
		created() {

		},
		methods: {
			reset() {
				this.account = '';
				this.passw = '';

			},
			submit() {
				let _this = this;
//				this.$axios.get('customer_login.action', {
//						params: {
//							account: this.account,
//							password: this.passw,
//						}
//					})
//					.then(function(response) {
//						if(response.data.resultCode == 1) {
//							_this.$router.push('home')
//						} else {
//							_this.$notify.error({
//								title: "错误",
//								message: "账号或者密码错误"
//							});
//						}
//					})
//					.catch(function(error) {
//						console.log(error);
//					});

// http://192.168.0.112/portal/graindemand_countGrainBuy.action

//let param = new URLSearchParams();
//param.append("type","0");

 this.$axios.get('graindemand_countGrainBuy.action', param)											
					.then(function(response) {
					 console.log(response);
					})
					.catch(function(error) {
						console.log(error);
					});
					

			},
			verify() {
				return new Promise((resolve, reject) => {
					if(!this.account) {
						reject('账号名不能为空');
					} else if(!this.passw) {
						reject('密码不能为空')
					} else {
						resolve()
					}
				})
			},
			login() {
				this.verify().then(() => {
						this.submit()
					})
					.catch(err => {
						this.$notify.error({
							title: "错误",
							message: err
						});
					})
			},
		},
		mounted() {

		}
	}
</script>

<style lang="scss" scoped="scoped">
	.content {
		position: absolute;
		width: 100%;
		height: 100%;
		background-image: url(../../assets/image/login.png);
		background-size: cover;
		.login {
			width: 300px;
			border: 1px solid #ccc;
			box-sizing: border-box;
			height: auto;
			background-color: white;
			position: absolute;
			left: 50%;
			top: 50%;
			transform: translate(-100%, -50%);
			text-align: center;
			padding: 30px;
			h4 {
				margin-top: 25px;
				margin-bottom: 25px;
			}
			.elInput {
				margin: 20px 0;
				outline: none;
			}
			.btn {
				margin-top: 25px;
				text-align: center;
				.el-button:nth-of-type(1) {
					margin-right: 30px;
				}
			}
		}
	}
</style>